<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/5/28 0028
 * Time: 下午 7:40
 */
namespace app\common\model;

use app\common\BaseHelper;
use think\Model;

class Useraccountdetails extends Model{
    protected $autoWriteTimestamp = true;
    //账户明细类型 0-普通订单账户支付  1-充值  2-退款退款回账户余额 3-开通会员 4-当面付余额支付 5-普通订单微信支付 6=当面付微信支付 7=退款回微信零钱
    const TYPE_0 = 0;
    const TYPE_1 = 1;
    const TYPE_2 = 2;
    const TYPE_3 = 3;
    const TYPE_4 = 4;
    const TYPE_5 = 5;
    const TYPE_6 = 6;
    const TYPE_7 = 7;

    const MODEL_1 = 1;//付钱
    const MODEL_2 = 2;//退钱

    public function insertRecord($data,$type,$model){


        /**
         * $Useraccountdetails = new Useraccountdetails();
        $Useraccountdetails->id = BaseHelper::getUUID();
        $Useraccountdetails->orderNO = $refundorder->orderNO;
        $Useraccountdetails->record_type = $type;
        $Useraccountdetails->money = $refundorder->actualrefund_fee;
        $Useraccountdetails->userId = $refundorder->userId;
        $Useraccountdetails->rechargeStatus = 1;
        $Useraccountdetails->tenantId = $refundorder->tenantId;
        $Useraccountdetails->storeId = $refundorder->storeId;
        $Useraccountdetails->payDate = $refundorder->endDate;
        $Useraccountdetails->transaction_id = $refundorder->transaction_Id;
        $Useraccountdetails->save();
         */

        $this->id = BaseHelper::getUUID();
        $this->record_type = $type;
        $this->rechargeStatus = 1;
        $this->orderNO = $data->orderNO;
        $this->tenantId = $data->tenantId;
        $this->storeId = $data->storeId;
        $this->transaction_id = $data->transaction_Id;
        if($model == 1){
            $this->userId = $data->createUser;
            $this->money = $data->total;
            $this->payDate = $data->payDate;
        }elseif ($model == 2){
            $this->userId = $data->userId;
            $this->money = $data->actualrefund_fee;
            $this->payDate = $data->endDate;
        }

        $this->save();

    }

}